//
//  OOWEbCJLCFMineWelfareGroupViewControllerULJuVy.m
//  qcb_ios
//
//  Created by Ji on 2018/9/3.
//  Copyright © 2018年 ski. All rights reserved.
//

#import "OOWEbCJLCFMineWelfareGroupViewControllerULJuVy.h"
#import "SegmentNavBar.h"
#import "iaUhLGJLCFMineRedPacketViewControlleroXOPGK.h"
#import "sQhlIkJLCFMineInterestViewControllergApCgY.h"


#define SEGNAVBAR_HEIGHT       50


@interface OOWEbCJLCFMineWelfareGroupViewControllerULJuVy ()

@property (nonatomic, strong) SegmentNavBar *navBar;
@property (nonatomic, strong) JLCFRootViewController *MsDkZyselectedViewControllerSipaUu;
@property (nonatomic, assign) NSInteger selectIndex;

@property (nonatomic, strong) iaUhLGJLCFMineRedPacketViewControlleroXOPGK *CMHanrredPacketVCIBBQho;
@property (nonatomic, strong) sQhlIkJLCFMineInterestViewControllergApCgY *NQGBVointerestVCTFBjIk;

@end

@implementation OOWEbCJLCFMineWelfareGroupViewControllerULJuVy

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addNavigationBar];
    [self addSegmentNavBar];
    [self initData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)addNavigationBar
{
    [super addNavigationBar];
    [self.navigationBar setTitle:@"我的福利"];
    
}

- (void)addSegmentNavBar
{
    self.navBar = [[SegmentNavBar alloc] initWithFrame:CGRectMake(0, NAVBAR_HEIGHT, FULL_WIDTH, SEGNAVBAR_HEIGHT)];
    self.navBar.backgroundColor = QTZ_White;
    [self.navBar didSelectedIndex:^(NSInteger index) {
        [self tabSelectAtIndex:index];
    }];
    [self.navBar setTitleArr:@[@"红包", @"加息券"]];
    [self.view addSubview:self.navBar];
    
}

- (void)initData
{
    self.selectIndex = -1;
    [self tabSelectAtIndex:0];
}

- (void)tabSelectAtIndex:(NSInteger)index
{
    if ( self.selectIndex != index) {
        
        self.selectIndex = index;
        
        if (self.MsDkZyselectedViewControllerSipaUu != nil) {
            [self.MsDkZyselectedViewControllerSipaUu willMoveToParentViewController:nil];
            [self.MsDkZyselectedViewControllerSipaUu.view removeFromSuperview];
            [self.MsDkZyselectedViewControllerSipaUu removeFromParentViewController];
        }
        
        if (0 == self.selectIndex) {
            self.MsDkZyselectedViewControllerSipaUu = self.CMHanrredPacketVCIBBQho;
        } else if (1 == self.selectIndex) {
            self.MsDkZyselectedViewControllerSipaUu = self.NQGBVointerestVCTFBjIk;
        }
        
        [self addChildViewController:self.MsDkZyselectedViewControllerSipaUu];
        
        [self.view insertSubview:self.MsDkZyselectedViewControllerSipaUu.view belowSubview:self.navigationBar];
        
        [self.MsDkZyselectedViewControllerSipaUu didMoveToParentViewController:self];
    }
}

- (iaUhLGJLCFMineRedPacketViewControlleroXOPGK *)CMHanrredPacketVCIBBQho
{
    if (!_CMHanrredPacketVCIBBQho) {
        _CMHanrredPacketVCIBBQho = [iaUhLGJLCFMineRedPacketViewControlleroXOPGK new];
    }
    return _CMHanrredPacketVCIBBQho;
}

- (sQhlIkJLCFMineInterestViewControllergApCgY *)NQGBVointerestVCTFBjIk
{
    if (!_NQGBVointerestVCTFBjIk) {
        _NQGBVointerestVCTFBjIk = [sQhlIkJLCFMineInterestViewControllergApCgY new];
    }
    return _NQGBVointerestVCTFBjIk;
}

@end
